import { mouseStatus } from "@/views/board/BoardEdit/LowCode/lib/const"

export default {
  state: {
    selectedComponentIndex: -1,
    selectedComponent: {
      style: {},
      props: {},
      events: {},
      jump: {},
      linkage: {}
    },
    canvasComponentList: [],

    selectedComponentStyle: {

    },
    mouseState: mouseStatus.DEFAUKT,
    geometric: {},

  },
  mutations: {
    setSelectedComponentIndex: (state, data)=> {
      state.selectedComponentIndex = data
    },
    setSelectedComponent: (state, data)=> {
      state.selectedComponent = data
    },
    setSelectedComponentStyle: (state, data)=> {
      state.selectedComponentStyle = data
    },
    setCanvasComponentList: (state, data)=> {
      state.canvasComponentList = data
    },
    setMouseStatusChange: (state, data)=> {
      state.mouseState = data
    },
    setGeometric: (state, data)=> {
      state.geometric = data
    },
    setWrapStyle({selectedComponent}, { top, left, width, height, rotate }) {
      if (top) selectedComponent.style.top = top
      if (left) selectedComponent.style.left = left
      if (width) selectedComponent.style.width = width
      if (height) selectedComponent.style.height = height
      if (rotate) selectedComponent.style.rotate = rotate
    },
  }
}

